package com.bangdream.michelia.view.fragment.main.live;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.andview.refreshview.XRefreshView;
import com.bangdream.michelia.R;
import com.bangdream.michelia.entity.LiveBean;
import com.bangdream.michelia.entity.courses.CoursesBean;
import com.bangdream.michelia.presenter.base.BasePresenter;
import com.bangdream.michelia.utils.L;
import com.bangdream.michelia.view.adapter.CurriculumChapterAdapter;
import com.bangdream.michelia.view.fragment.currency.BaseFragment;

/**
 * @date on 2018/7/23 17:51
 * @email 909732184@qq.com
 * 直播详情-章节
 */
public class LiveDetailsChapter extends BaseFragment {
    private View view;
    private XRefreshView refreshView;
    private RecyclerView recyclerView;
    private LinearLayoutManager linearLayoutManager;
    private CurriculumChapterAdapter adapter;
    private LiveBean data;
    private TextView tvNumber;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.curriculum_chapter,container,false);
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        init();
    }

    @Override
    public BasePresenter createPresenter() {
        return null;
    }

    private void init() {
        if(getArguments()!=null){
            data = getArguments().getParcelable("data");
        }
        refreshView = view.findViewById(R.id.refreshView);
        tvNumber = view.findViewById(R.id.tvNumber);
        refreshView.setPullLoadEnable(false);
        refreshView.setPullRefreshEnable(false);
        linearLayoutManager = new LinearLayoutManager(getActivity());
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView = view.findViewById(R.id.recyclerView);
        recyclerView.setLayoutManager(linearLayoutManager);
        adapter = new CurriculumChapterAdapter(getActivity());
        recyclerView.setAdapter(adapter);
        setViewData(data);
    }


    private void setViewData(LiveBean data) {
        this.data = data;
        if(data==null)
            return;
        L.d(data.toString());
        //tvNumber.setText("(共"+(data.getChapterList()==null?"0":data.getChapterList().size())+"个章节)");
        //adapter.setData(data.getChapterList());
    }

}
